/*
 * Copyright (C) 2017-2025
 * ZKMall All rights reserved, Designed By 深圳中科鑫智科技有限公司
 * Copyright authorization contact 18814114118
 */
package com.shop.zkmall.admin.service.express.impl;

import com.shop.zkmall.admin.dao.express.CerePlatformExpressDAO;
import com.shop.zkmall.admin.param.express.ExpressUpdateParam;
import com.shop.zkmall.admin.service.express.CerePlatformExpressService;
import com.shop.zkmall.admin.service.log.CerePlatformLogService;
import com.shop.zkmall.commons.domain.express.CerePlatformExpress;
import com.shop.zkmall.commons.domain.user.CerePlatformUser;
import com.shop.zkmall.commons.exception.CoBusinessException;
import com.shop.zkmall.commons.utils.TimeUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author zkmall zkmallvip@163.com
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class CerePlatformExpressServiceImpl implements CerePlatformExpressService {

    private final CerePlatformExpressDAO cerePlatformExpressDAO;

    private final CerePlatformLogService cerePlatformLogService;

    @Override
    @Transactional(isolation = Isolation.DEFAULT, propagation = Propagation.REQUIRED, rollbackFor = {CoBusinessException.class, Exception.class})
    public void update(ExpressUpdateParam param, CerePlatformUser user) {
        String time = TimeUtils.yyMMddHHmmss();
        CerePlatformExpress express = new CerePlatformExpress();
        express.setExpressType(param.getExpressType());
        express.setPlatformUserId(user.getPlatformUserId());
        express.setUpdateTime(time);
        cerePlatformExpressDAO.updateExpress(express);
        //新增日志
        cerePlatformLogService.addLog(user, "物流查询策略", "平台端操作", "修改物流查询策略", String.valueOf(express.getPlatformUserId()), time);
    }
}
